package com.yunji.cabinet.dao.impl;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.yunji.base.bo.ChangeBindBO;
import com.yunji.cabinet.dao.ICabinetTemplateDao;
import com.yunji.cabinet.domain.CabinetTemplateDO;
import com.yunji.cabinet.dto.CabinetFiledDTO;
import com.yunji.cabinet.mapper.CabinetTemplateMapper;
import com.yunji.common.base.BaseDaoImpl;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

@Repository
public class CabinetTemplateDaoImpl extends BaseDaoImpl<CabinetTemplateMapper, CabinetTemplateDO> implements ICabinetTemplateDao {

    @Resource
    CabinetTemplateMapper cabinetTemplateMapper;

    @Override
    public List<String> searchTableField(CabinetFiledDTO params) {
        return cabinetTemplateMapper.searchTableField(params);
    }

    @Override
    public boolean changeAgent(ChangeBindBO bo) {
        return update(new LambdaUpdateWrapper<CabinetTemplateDO>()
                .set(CabinetTemplateDO::getBelongId, bo.getBelongId())
                .set(CabinetTemplateDO::getAgentId, bo.getAgentId())
                .eq(CabinetTemplateDO::getSiteId, bo.getSiteId()));
    }
}
